{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Getting started with `sbi`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Note, you can find the original version of this notebook at [https://github.com/sbi-dev/sbi/blob/main/tutorials/00_getting_started.ipynb](https://github.com/sbi-dev/sbi/blob/main/tutorials/00_getting_started.ipynb) in the `sbi` repository."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "from sbi import utils as utils\n",
    "from sbi import analysis as analysis\n",
    "from sbi.inference.base import infer"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Running the inference procedure\n",
    "\n",
    "`sbi` provides a simple interface to run state-of-the-art algorithms for simulation-based inference."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For inference, you need to provide two ingredients:\n",
    "\n",
    "1) a prior distribution that allows to sample parameter sets.  \n",
    "2) a simulator that takes parameter sets and produces simulation outputs.\n",
    "\n",
    "For example, we can have a 3-dimensional parameter space with a uniform prior between [-1,1] and a simple simulator that for the sake of example adds 1.0 and some Gaussian noise to the parameter set:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "num_dim = 3\n",
    "prior = utils.BoxUniform(low=-2 * torch.ones(num_dim), high=2 * torch.ones(num_dim))\n",
    "\n",
    "def simulator(parameter_set):\n",
    "    return 1.0 + parameter_set + torch.randn(parameter_set.shape) * 0.1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`sbi` can then run inference:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "60bf691ee48c4e53b628daa1b77d46ef",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Running 1000 simulations.:   0%|          | 0/1000 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Neural network successfully converged after 119 epochs."
     ]
    }
   ],
   "source": [
    "# Other methods are \"SNLE\" or \"SNRE\".\n",
    "posterior = infer(simulator, prior, method=\"SNPE\", num_simulations=1000)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's say we have made some observation $x$:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "observation = torch.zeros(3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    " Given this observation, we can then sample from the posterior $p(\\theta|x)$, evaluate its log-probability, or plot it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "09707f2acd1b4db7984c020e063c416d",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Drawing 10000 posterior samples:   0%|          | 0/10000 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWUAAAGBCAYAAAC+UKAvAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAlSklEQVR4nO3dXYxk513n8e//OefUS/e03fY4xs7YwYtWG62UBUNCssqYCwaiDYlQIhEkXrRopdwgcUGk5WJEJJRFQszVwiVC2axzgRYWARLaEKGsJlISe5O18SZxbBMrBId4Eojf2tMv9XbO+e/Fc6q7eqZ7prunqs/T3b+P1HJVdXXN066uXz31P8/zP+buiIhIGkLbAxARkR0KZRGRhCiURUQSolAWEUmIQllEJCEKZRGRhORH+BmtoUuHzeuB3hd+Uc9rIj5X//ncnlf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tmP3vEx+mZ2f81s681ndj+y3xHeny0zVpEkuDuv3MHPz4CLrn7RrN77ktm9ll3//KchndsNFMWkWNlZh83sxfN7EvA22duf9zMPtJcfsnMfr/ZLv60mf2Emf2tmf2Dmf36jY/p0UZztWi+TuQmDIWyiBwbM3sn8EvAo8AHgJ+8xd3/yd0fJe6Gexz4CPDvgT1LE2aWmdlXgR8An3P3fTuxpUyhLCLH6aeAv3L3raZT2l/f4r7T7z0LfMXd1939FWBkZqs33tndqybEHwLebWbvmO/Qj4dCWURSNWr+W89cnl7f93iYu68Bnwfev7CRLZBCWUSO0xeAD5tZvzk10s/P40HN7C3T2bOZ9YmnkPr7eTz2cdPqCxE5Ns156v4M+Bqx9vvUnB76QeDTzXn9AvA/3f1/zemxj5W6xImIJETlCxGRhCiURUQSolAWEUmIQllEJCEKZRGRhCiURUQSolAWEUmIQllEJCH/HyiwHdMlwo1eAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 432x432 with 9 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "samples = posterior.sample((10000,), x=observation)\n",
    "log_probability = posterior.log_prob(samples, x=observation)\n",
    "_ = analysis.pairplot(samples, limits=[[-2, 2], [-2, 2], [-2, 2]], figsize=(6, 6))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Next steps\n",
    "\n",
    "The single-line interface described above provides an easy entry for using `sbi`. However, on almost any real-world problem that goes beyond a simple demonstration, we strongly recommend using the [flexible interface](https://sbi-dev.github.io/sbi/tutorial/02_flexible_interface/)."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
